/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

int path(struct TreeNode* node, int addSum, int targetSum)
{
     if(!node)
       return 0;

     addSum += node->val;

     int left = path(node->left, addSum, targetSum);
     
     if(left == 1)
       return 1; 
     
     int right = path(node->right, addSum, targetSum);
     
     if(right == 1)
        return 1;
    
     if(!node->left && !node->right && addSum==targetSum){
         return 1;
     }

     return 0;  
}

bool hasPathSum(struct TreeNode* root, int targetSum){
  int IsHasPathSum = path(root, 0, targetSum);
  if(IsHasPathSum==1){
      return true;
  }
  return false;
}
